﻿using System.Configuration;
using System.Threading;

namespace Wild2.Models.Twitter
{
    public class Tweet
    {
        public static void SendTwit(string url, string text, string where)
        {
            url = ConfigurationManager.AppSettings["domain"] + url;
            url = Text.Helper.CutUrl(url);
            string twit = where + ": " + Text.Helper.Cutstring(text, 80 - url.Length - where.Length, 80 - url.Length - where.Length) + "   " + url + " #calendar #mobile #ovulation #lady";

            Thread th = new Thread(new ThreadStart(() =>
            {
                Twitterizer.OAuthTokens tok = new Twitterizer.OAuthTokens();
                tok.ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
                tok.ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
                tok.AccessToken = ConfigurationManager.AppSettings["AccessToken"];
                tok.AccessTokenSecret = ConfigurationManager.AppSettings["AccessTokenSecret"];
                Twitterizer.TwitterStatus.Update(tok, twit);
            }));
            th.Start();
        }
    }
}